﻿@using KXCXW.Web.CommonClass.Ext
@using KXCXW.Web.CommonClass
@using kxcxw.Data.Common
@model IEnumerable<kxcxw.Data.Entities.PublichInformation>
@if (Model != null && Model.Count() > 0)
{
    int modelCount = Model.Count();
    int infoNumPerRow = 4;
    int i = 0;
    int typeId = ViewData["type"] != "" ? Convert.ToInt32(ViewData["typeId"]) : 1;
    while (i < modelCount)
    {
    <ul>
        @for (int j = 0; j < infoNumPerRow && i < modelCount; j++)
        {
            var elItem = Model.ElementAt(i);
            var url = elItem.InfoType == 1 ? elItem.ShopUrl : Url.Action("ProductDetails", "Home", new { id = elItem.InformationID });
            DateTime TempDate = DateTime.Now.AddDays(-DataConstants.ExpirationDay);
            bool isExpared = false;
            if (!((elItem.EndDate == null && elItem.PublishDate >= TempDate) || elItem.EndDate >= DateTime.Now))
            {
                isExpared = true;
            }
            <li class="product"><a href='javascript:visitInfo("@url","@elItem.InformationID");' productId="@elItem.InformationID"  class="pic line_01 @(elItem.InfoType == 1 ? "weburl" : "")">
                <textarea class="switch_textarea"><img class="JIATHIS_IMG_OK" title="@elItem.Title" alt="@elItem.Title" src="@Url.Content(ImgHelper.ImgFoldUrl(ImgHelper.img160) + (string.IsNullOrEmpty(elItem.MapUrl) ? "nullImage.jpg" : elItem.MapUrl))" /></textarea>
            </a>
                @if (elItem.PromotionType == DataConstants.PanicBuying)
                {
                    TimeSpan ts = new TimeSpan();
                    int days = 30;
                    if (elItem.EndDate != null)
                    {
                        ts = elItem.EndDate.Value - DateTime.Now;
                        days = Convert.ToInt32(ts.TotalDays) + 1;
                    }
                    <s>原价：￥@elItem.OriginalPrice</s> 
                    <span>抢购价：￥@elItem.PresentPrice</span>
                          if (!isExpared)
                          {
                    <div class="discount red">
                        <span>@days.ToString()</span>
                        <p>
                            天</p>
                    </div>
                          }
                }
                else if (elItem.PromotionType == DataConstants.Discount)
                {
                    <s>原价：￥@elItem.OriginalPrice</s> 
                    <span>折扣价：￥@elItem.PresentPrice</span> 
                          if (elItem.Discount <= 8 && !isExpared)
                          {
                    <div class="discount red">
                        <span>@string.Format("{0:0.0}", elItem.Discount)</span>
                        <p>
                            折</p>
                    </div>
                          }
                }
                else if (elItem.PromotionType == DataConstants.PriceReduction)
                {
                    decimal sheng = elItem.OriginalPrice - elItem.PresentPrice;
                    <s>原价：￥@elItem.OriginalPrice</s> 
                    <span>处理价：￥@elItem.PresentPrice</span> 
                          if (!isExpared)
                          {
                    <div class="discount red PriceReduction">
                        <p>
                            省</p>
                        <span>@string.Format("{0:0}", sheng)</span>
                    </div>
                          }
                }
                else if (elItem.PromotionType == DataConstants.BuyAdd)
                {
                    <span>价格：￥@elItem.PresentPrice</span> 
                         if (!isExpared)
                         {
                    <div class="discount red BuyAdd">
                        <s>购赠</s>
                    </div>
                         }
                    <span style="color: Red; font-weight: normal;">赠品：@Html.Truncate(elItem.Other, 8)</span> 
                }
                else if (elItem.PromotionType == DataConstants.Clearance)
                {
                    <s>原价：￥@elItem.OriginalPrice</s> 
                    <span>清仓价：￥@elItem.PresentPrice</span> 
                          if (!isExpared)
                          {
                    <div class="discount red BuyAdd">
                        <s>清仓</s>
                    </div>
                          }
                }
                @if (isExpared)
                {
                    <div class="discount isExpared">
                    </div>
                }
                <a href='javascript:visitInfo("@url","@elItem.InformationID");' class="proname @(elItem.InfoType == 1 ? "weburl" : "")" title="@elItem.Title" productId="@elItem.InformationID">@Html.Truncate(elItem.Title, 12)</a>
            </li>
                                                                                                                                                          i++;
        }
    </ul>
    <div class="clear">
    </div>      
    }
}
<script type="text/javascript">

    function visitInfo(pUrl, pInfoId) {
        $.ajax({
            url: "",
            data: {},
            success: function (retData) {
                
            },
            error: function (xhrObj,textStatus,errObj) { 
                
            }
        });
        window.open(pUrl);
    }

</script>
